Комнату может создать только
зарегистрированный пользователь!

Закрыть!
0 ) { $sql = " select count(*) cnt from presence where room_id = $room_id "; if( $query = mysql_query( $sql ) ) { if( $row = mysql_fetch_array( $query ) ) { $there_are_people = $row[cnt]; } } else { echo "cant execute '$sql'"; } mysql_free_result($query); } if( $room_id > 0 && $there_are_people > 0 ) { $sql = " insert into wishes ( user_id, room_id, set_date, what, explanation, object_id ) values ( $user_id, $room_id, sysdate(), 'A', null, null ) "; if( !mysql_query( $sql ) ) { echo "cant execute '$sql'"; } $text = addslashes( "Пользователь $user_name хочет войти к нам!" ); $sql = "insert into chats ( set_date, sender_id, rooms, whom, message, type, subtype ) values ( sysdate(), $user_id, $room_id, null, '$text', 'S', 'A' ) "; if( !mysql_query( $sql ) ) { printError( "cant execute '$sql'" ); } echo "Комната уже создана, подождите пока присутствующие там разрешат Вам войти"; } else { // no club room $sql = " select club_id id, club_name name, club_discription description, club_moderator_id moderator_ids from club_server.clubs where club_id = $club_id "; $name = $theme = ""; if( $query = mysql_query( $sql ) ) { if( $row = mysql_fetch_array( $query ) ) { $club_id = $row[id]; $name = $row[name]; $theme = $row[description]; $moderator_ids = $row[moderator_ids]; } } else { echo "what an '$sql'\n"; } if( $club_id ) { $sql = " insert into rooms (id, set_date, initiator_id, moderator_ids, name, theme, type, bg_color, club_id, empty_date) values (null, sysdate(), $user_id, ':$moderator_ids:', '$name', '$theme', 'C', null, $club_id, null) "; if( !$there_are_people && !mysql_query($sql) ) { echo "Невозможно создать комнату!"; } else { $room_id = mysql_insert_id(); echo "Комната успешно создана!"; $sql = " insert into presence (room_id, user_id, enter_date) values ($room_id, $user_id, sysdate()) "; if( !mysql_query($sql) ) { echo " Однако войти туда не получилось."; } $sql = " insert into chats ( set_date, sender_id, rooms, whom, message, type, subtype ) values ( sysdate(), $user_id, ':$room_id:', null, 'Вы создали новую комнату', 'S', 'E' ) "; if( !mysql_query( $sql ) ) { } } } else { echo "Нет такого клуба!"; } } ?>
Вперед